import * as Api from '@/api/system/employee'

const employee = {
  state: {
  },
  mutations: {
  },
  actions: {
    GetEmployeePage({ commit }, param) {
      return new Promise((resolve, reject) => {
        Api.getEmployeePage(param)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    GetEmployeeById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.getEmployeeById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    SaveEmployee({ commit }, data) {
      return new Promise((resolve, reject) => {
        Api.saveEmployee(data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    UpdateEmployeeById({ commit }, { id, data }) {
      return new Promise((resolve, reject) => {
        Api.updateEmployeeById(id, data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    RemoveEmployeeById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.removeEmployeeById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    }
  }
}

export default employee
